package circuits;

import java.util.Iterator;

public class XorOperator extends Operator{

	@Override
	protected void calculateResult() {
		Iterator<Operation> operandsIterator = this.operands.iterator();
		boolean xorResult = false;
		if (operandsIterator.hasNext()){
			boolean firstResult = operandsIterator.next().result;
			while (operandsIterator.hasNext()){
				boolean otherResult = operandsIterator.next().result;
				if (otherResult != firstResult){
					xorResult = true;
					break;
				}
			}
		}
		this.setResultAndNotifyListeners(xorResult);
	}
}
